<% layout('/layouts/default.html', {title: '广告获客管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('广告获客管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-navicon"></i> <span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnExport"><i class="glyphicon glyphicon-export"></i> 导出</a></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${adGuest}" action="${ctx}/ad/adGuest/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<#form:input path="ad.id" maxlength="64" class="form-control width-120" style ="display:none"/>
				<div class="form-group">
					<label class="control-label">${text('广告主')}：</label>
					<div class="control-inline">
						<#form:input path="adVertiser.account" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('联系电话')}：</label>
					<div class="control-inline">
						<#form:input path="mobile" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('号码归属')}：</label>
					<div class="control-inline">
						<#form:input path="mobileLocation" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('性别')}：</label>
					<div class="control-inline width-120">
						<#form:select path="sex" dictType="sys_user_sex" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('手机型号')}：</label>
					<div class="control-inline">
						<#form:input path="mobileKind" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('年龄')}：</label>
					<div class="control-inline">
						<#form:input path="age_gte" maxlength="2" class="form-control width-60"/>
						&nbsp;--&nbsp;
						<#form:input path="age_lte" maxlength="2" class="form-control width-60"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('职业')}：</label>
					<div class="control-inline">
						<#form:input path="career" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('投放媒体')}：</label>
					<div class="control-inline">
						<#form:input path="comeFrom" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('获客时间')}：</label>
					<div class="control-inline">
						<#form:input path="guestTime_gte" readonly="true" maxlength="20" class="form-control Wdate-datetime"
							dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false,onpicked:function(){guestTime_lte.click()}});"/>
						&nbsp;--&nbsp;
						<#form:input path="guestTime_lte" readonly="true" maxlength="20" class="form-control Wdate-datetime"
							dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('广告计划名称')}：</label>
					<div class="control-inline">
						<#form:input path="ad.name" maxlength="300" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('有效性')}：</label>
					<div class="control-inline width-120">
						<#form:select path="validStatus" dictType="guest_status" multiple="false" blankOption="true" class="form-control" />
					</div>
				</div>
				<!-- <div class="form-group">
					<label class="control-label">${text('消费')}：</label>
					<div class="control-inline width-120">
						<#form:select path="consumptionStatus" dictType="consumption_status" multiple="false" blankOption="true" class="form-control"/>
					</div>
				</div> -->
                <div class="form-group">
					<label class="control-label">${text('媒体页URL')}：</label>
					<div class="control-inline">
						<#form:input path="mediaUrl" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('广告位ID')}：</label>
					<div class="control-inline">
						<#form:input path="mediaAdId" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('落地页URL')}：</label>
					<div class="control-inline">
						<#form:input path="toGroundUrl" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('停留时间(秒)')}：</label>
					<div class="control-inline">
						<#form:input path="stopTime" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('留言内容')}：</label>
					<div class="control-inline">
						<#form:input path="message" maxlength="1024" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注信息')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="500" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("联系电话")}', name:'mobile', index:'a.mobile', width:250, align:"left"},
		{header:'${text("号码归属")}', name:'mobileLocation', index:'a.mobile_location', width:150, align:"left"},
		{header:'${text("手机型号")}', name:'mobileKind', index:'a.mobile_kind', width:150, align:"left"},
		{header:'${text("性别")}', name:'sex', index:'a.sex', width:70, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_sex')}, val, '${text("未知")}', true);
		}},
		{header:'${text("年龄")}', name:'age', index:'a.age', width:70, align:"center"},
		{header:'${text("职业")}', name:'career', index:'a.career', width:150, align:"left"},
		{header:'${text("广告主")}', name:'adVertiser.account', index:'u11.account', width:150, align:"left"},
        {header:'${text("广告计划名称")}', name:'ad.name', index:'u10.name', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
        	if(row.ad != null && row.ad != ''){
        		 return '<a href="${ctx}/ad/ad/listByAd?adId='+row.ad.id+'&adName='+row.ad.name+'" class="btnList" data-title="${text("广告计划名称")}">'+(val||row.ad.name)+'</a>';
        	}else{
        		return '';
        	}
        }},
		{header:'${text("投放媒体")}', name:'comeFrom', index:'a.come_from', width:150, align:"left"},
        {header:'${text("媒体页URL")}', name:'mediaUrl', index:'a.media_url', width:150, align:"left", formatter: function(val, obj, row, act){
        	if(row.mediaUrl==null||row.mediaUrl==''){
    			return '';
        	}else{
        		return '<a href="'+row.mediaUrl+'";>'+row.mediaUrl+'</a>&nbsp;';
        	}
        }},
		{header:'${text("广告位ID")}', name:'mediaAdId', index:'a.media_ad_id', width:150, align:"left"},
        {header:'${text("落地页URL")}', name:'toGroundUrl', index:'a.to_ground_url', width:150, align:"left", formatter: function(val, obj, row, act){
        	if(row.toGroundUrl==null||row.toGroundUrl==''){
    			return '';
        	}else{
        		return '<a href="'+row.toGroundUrl+'";>'+row.toGroundUrl+'</a>&nbsp;';
        	}
        }},
		{header:'${text("获客时间")}', name:'guestTime', index:'a.guest_time', width:150, align:"center"},
		{header:'${text("停留时间(秒)")}', name:'stopTime', index:'a.stop_time', width:150, align:"center"},
		{header:'${text("留言内容")}', name:'message', index:'a.message', width:150, align:"left"},
		{header:'${text("有效性")}', name:'validStatus', index:'a.valid_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('guest_status')}, val, '${text("")}', true);
		}},
		{header:'${text("备注信息")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		/* {header:'${text("消费")}', name:'consumptionStatus', index:'a.consumption_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('consumption_status')}, val, '${text("")}', true);
		}}, */
		{header:'${text("音频文件")}', name:'audioUploadId', index:'a.audioUploadId', width:150, align:"left",sortable:false, formatter: function(val, obj, row, act){
        	if(row.audioUploadId==null||row.audioUploadId==''){
    			return '';
        	}else{
        		return '<a target="_blank" href="${ctx}/ad/adGuest/play?id='+row.id+'">播放</a>&nbsp;';
        	}
        }},
		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text("操作")}', name:'actions', width:140, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('ad:adGuest:edit')){ %>
				actions.push('<a href="${ctx}/ad/adGuest/form?id='+row.id+'" class="btnList" title="${text("编辑广告获客")}"><i class="fa fa-pencil"></i></a>&nbsp;');
			<% } %>
			<% if(hasPermi('ad:adGuest:view')){ %>
				actions.push('<a href="${ctx}/ad/adGuest/detail?id='+row.id+'" class="btnList" title="${text("广告获客详情")}"><i class="fa fa-eye"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
$('#btnExport').click(function(){
	js.ajaxSubmitForm($('#searchForm'), {
		url:'${ctx}/ad/adGuest/exportData',
		downloadFile:true
	});
});
$(function(){
	$("th").attr("height","55px!important");
});
</script>